<template>
	<view class="">
		<view class="p15 bg-white">

			<view class="u-flex">
				
				<view class="brs5 p10 u-f1 " style="border: 1px solid #eee;">
					<input :password="true" maxlength="6" placeholder="请输入支付密码" v-model="password" type="number" style="padding-left: 0;" />
				</view>
			</view>
			
			
		</view>
		<view class="fixed-bottom module-btn" style="position: inherit;">
			<button type="primary" @click="save" class="btn mt15">确认</button>
		</view>
		<u-picker mode="selector" range-key="name" @confirm="popupConfirm" v-model="pupopShow"
			:range="popupList"></u-picker>

		<wanl-address ref='wanlAddress' @resetAddress="resetAddress"
			@selectAddress="successSelectAddress"></wanl-address>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				password:'',
				popupList: [],
				popupFiled: '',
				search: {},
				pupopShow: false,
				defaultIndex: [0, 0, 0],
				show: false,
				navTitle: "添加地址",
				serveList: [],
				storeList: [],
				form: {
					shop_id: '',
					shop_id_name: ''
				}
			}
		},
		onLoad(options) {
			this.initData()
			this.getList()
		},
		onShow() {

			if (uni.getStorageSync('storeInfo')) {
				let item = JSON.parse(uni.getStorageSync('storeInfo'))

				this.form.shop_id = item.id
				this.form.shop_id_name = item.shopname
				uni.setStorageSync('storeInfo', '')
			}
		},
		computed: {},
		methods: {
			resetAddress() {
				this.search.area = ``
				this.search.province_id = '';
				this.search.city_id = '';
				this.search.area_id = '';
				this.getList()
			},
			areaClick() {
				this.$refs.wanlAddress.show()
			},
			successSelectAddress(address) {
				console.log(address)
				// ${address.province}-${address.city}-
				this.search.area = `${address.province}-${address.city}-${address.district}`
				this.search.province_id = address.ids[0];
				this.search.city_id = address.ids[1];
				this.search.area_id = address.ids[2];
				this.getList()

			},
			popupConfirm(e) {
				let idx = e[0]
				this.form[this.popupFiled] = this.popupList[idx].id
				this.form[this.popupFiled + '_name'] = this.popupList[idx].name
				console.log(e, 122)
			},
			save() {

				uni.request({
					url: '/wanlshop/index/resetPayPwd',
					data: {
						password:this.password
					},
					method: 'POST',
					complete: res => {
						console.log(res, 1212)
						if (res.res.code === 1) {
							uni.showToast({
								title: '设置成功'
							})
							setTimeout(() => {
								uni.navigateBack()
							}, 1500)
						} else {
							uni.showToast({
								title: res.res.msg,
								icon: 'none'
							})
						}
					}
				});
			}
		},
		mounted() {

		}
	}
</script>

<style>
	.btn {
		border-radius: 16rpx;
	}
</style>